﻿#pragma once

#include <string>

namespace xy
{

namespace topo
{

class property_t
{
  public:
    /**
     * @brief 基本构造
     *
     * @param[in] name
     */
    property_t(std::string name) : m_name(name)
    {
    }

    /**
     * @brief 空析构
     *
     */
    virtual ~property_t() = default;

    /**
     * @brief 返回属性名
     *
     * @return  std::string
     */
    std::string name() const noexcept
    {
        return m_name;
    }

  protected:
    std::string m_name;
};

template <typename T> class property_handle : public property_t
{
  public:
    /**
     * @brief 基本构造
     *
     * @param[in] name
     */
    property_handle(std::string name) : property_t(name), m_t(T{})
    {
    }

    /**
     * @brief 返回属性值
     *
     * @return  const T&
     */
    const T &property() const noexcept
    {
        return m_t;
    }

    /**
     * @brief 返回属性值
     *
     * @return  T&
     */
    T &property() noexcept
    {
        return m_t;
    }

  protected:
    T m_t;
};

} // namespace topo

} // namespace xy
